import 'package:flutter/material.dart';
import '../models/list_item.dart';

class ListProvider with ChangeNotifier {
  final List<ListItem> _items = [
    ListItem("邮件", Icons.email, Colors.blue),
    ListItem("日历", Icons.calendar_today, Colors.green),
    ListItem("云盘", Icons.cloud, Colors.orange),
    ListItem("设置", Icons.settings, Colors.purple),
    ListItem("消息", Icons.message, Colors.red),
    ListItem("音乐", Icons.music_note, Colors.teal),
    ListItem("地图", Icons.map, Colors.brown),
    ListItem("购物车", Icons.shopping_cart, Colors.deepOrange),
  ];

  List<ListItem> get items => _items;

  void addItem(ListItem item) {
    _items.add(item);
    notifyListeners(); // 通知所有监听者状态已更新
  }

  void removeItem(int index) {
    _items.removeAt(index);
    notifyListeners();
  }

  void updateItem(int index, ListItem newItem) {
    _items[index] = newItem;
    notifyListeners();
  }

  void shuffleItems() {
    _items.shuffle();
    notifyListeners();
  }
}